<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Django网络投票系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 基础样式 - 与detail.html完全一致 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            color: #333;
        }
        
        .container {
            width: 100%;
            max-width: 900px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }
        
        header {
            background: linear-gradient(to right, #4b6cb7, #182848);
            color: white;
            padding: 25px 40px;
            text-align: center;
            position: relative;
        }
        
        header h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            letter-spacing: 1px;
        }
        
        header p {
            opacity: 0.9;
            font-size: 1.1rem;
        }
        
        .content {
            padding: 40px;
        }
        
        .card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
            padding: 30px;
            margin-bottom: 30px;
            transition: transform 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
        }
        
        .card h2 {
            color: #2c3e50;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #e0e6ed;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
        }
        
        .card h2 i {
            margin-right: 12px;
            color: #4b6cb7;
        }
        
        .question-list {
            list-style-type: none;
        }
        
        .question-item {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            transition: all 0.3s ease;
            border-left: 4px solid #4b6cb7;
            cursor: pointer;
        }
        
        .question-item:hover {
            background: #e9f7fe;
            transform: translateX(5px);
            border-left: 4px solid #3498db;
        }
        
        .question-item a {
            color: #2c3e50;
            text-decoration: none;
            font-size: 1.2rem;
            font-weight: 500;
            flex-grow: 1;
            display: flex;
            align-items: center;
        }
        
        .question-item a i {
            margin-right: 12px;
            color: #4b6cb7;
        }
        
        .question-item .date {
            color: #7f8c8d;
            font-size: 0.9rem;
            background: #e0e6ed;
            padding: 5px 12px;
            border-radius: 20px;
            margin-left: 15px;
        }
        
        .empty-message {
            text-align: center;
            padding: 40px;
            color: #7f8c8d;
            font-size: 1.1rem;
        }
        
        .empty-message i {
            font-size: 3rem;
            margin-bottom: 15px;
            color: #bdc3c7;
        }
        
        .buttons {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 20px;
        }
        
        .btn {
            padding: 14px 28px;
            border-radius: 50px;
            border: none;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: all 0.3s ease;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
            text-decoration: none;
        }
        
        .btn i {
            margin-right: 8px;
        }
        
        .btn-home {
            background: #2c3e50;
            color: white;
        }
        
        .btn-home:hover {
            background: #1a252f;
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
        }
        
        .btn-add {
            background: #27ae60;
            color: white;
        }
        
        .btn-add:hover {
            background: #219653;
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
        }
        
        .btn-admin {
            background: #9b59b6;
            color: white;
        }

        .btn-admin:hover {
            background: #8e44ad;
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
        }

        .stats {
            display: flex;
            justify-content: space-around;
            text-align: center;
            margin-top: 30px;
            padding: 25px;
            background: #f8f9fa;
            border-radius: 15px;
        }
        
        .stat-item {
            padding: 0 20px;
        }
        
        .stat-number {
            font-size: 2.2rem;
            font-weight: 700;
            color: #2c3e50;
            margin-bottom: 5px;
        }
        
        .stat-label {
            color: #7f8c8d;
            font-size: 1rem;
        }
        
        footer {
            text-align: center;
            padding: 25px;
            color: #7f8c8d;
            background: #f8f9fa;
            border-top: 1px solid #e0e6ed;
            font-size: 0.95rem;
        }
        
        /* 响应式设计 - 与detail.html一致 */
        @media (max-width: 768px) {
            .content {
                padding: 25px;
            }
            
            header h1 {
                font-size: 2rem;
            }
            
            .card h2 {
                font-size: 1.6rem;
            }
            
            .question-item {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .question-item a {
                margin-bottom: 10px;
            }
            
            .question-item .date {
                margin: 10px 0 0;
                align-self: flex-end;
            }
            
            .buttons {
                flex-direction: column;
                gap: 10px;
            }
            
            .btn {
                justify-content: center;
            }
            
            .stats {
                flex-direction: column;
                gap: 20px;
                padding: 20px;
            }
            
            .stat-item {
                padding: 10px 0;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-poll"></i> 网络投票系统</h1>
            <p>参与投票，表达您的意见</p>
        </header>
        
        <div class="content">
            <div class="card">
                <h2><i class="fas fa-list"></i> 最新投票问题</h2>
                
                {% if latest_question_list %}
                    <ul class="question-list">
                    {% for question in latest_question_list %}
                        <li class="question-item">
                            <a href="{% url 'polls:detail' question.id %}">
                                <i class="fas fa-question-circle"></i> 
                                {{ question.question_text }}
                            </a>
                            <span class="date">{{ question.pub_date|date:"Y-m-d" }}</span>
                        </li>
                    {% endfor %}
                    </ul>
                {% else %}
                    <div class="empty-message">
                        <i class="fas fa-inbox"></i>
                        <p>目前没有可用的投票</p>
                    </div>
                {% endif %}
            </div>
            
            <div class="stats">
                <div class="stat-item">
                    <div class="stat-number">{{ latest_question_list|length }}</div>
                    <div class="stat-label">进行中的投票</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number">142</div>
                    <div class="stat-label">总投票数</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number">32</div>
                    <div class="stat-label">参与用户</div>
                </div>
            </div>
            
            <div class="buttons">
                <a href="{% url 'polls:index' %}" class="btn btn-home">
                    <i class="fas fa-home"></i> 返回首页
                </a>
                <a href="/admin/polls/question/add/" class="btn btn-add">
                    <i class="fas fa-plus-circle"></i> 创建新投票
                </a>
                <a href="/admin/" class="btn btn-admin">
                    <i class="fas fa-cog"></i> 后台管理
                </a>
            </div>
        </div>
        
        <footer>
            <p>© 2023 Django网络投票系统 | 使用Django 4.2构建 | 共{{ latest_question_list|length }}个投票问题</p>
        </footer>
    </div>

    <script>
        // 为每个问题项添加点击效果
        document.querySelectorAll('.question-item').forEach(item => {
            item.addEventListener('click', function(e) {
                // 如果点击的不是链接本身，则触发链接点击
                if (!e.target.matches('a') && !e.target.matches('a *')) {
                    this.querySelector('a').click();
                }
            });
        });
        
        // 初始化动画效果
        document.addEventListener('DOMContentLoaded', function() {
            // 卡片入场动画
            const cards = document.querySelectorAll('.card');
            cards.forEach((card, index) => {
                card.style.opacity = '0';
                card.style.transform = 'translateY(20px)';
                card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                
                setTimeout(() => {
                    card.style.opacity = '1';
                    card.style.transform = 'translateY(0)';
                }, 100 + (index * 100));
            });
            
            // 问题项悬停效果增强
            const questionItems = document.querySelectorAll('.question-item');
            questionItems.forEach(item => {
                item.addEventListener('mouseenter', function() {
                    this.style.boxShadow = '0 5px 15px rgba(0, 0, 0, 0.1)';
                });
                
                item.addEventListener('mouseleave', function() {
                    this.style.boxShadow = 'none';
                });
            });
        });
    </script>
</body>
</html>